package ycj.learn.spring.ioc.common;

import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class TradeService {
    @Resource
    private MoneyService moneyService;
    @Resource
    private InventoryService inventoryService;


    public void trade(String buyer, String seller, int num) {
        final int PRICE = 10;

        moneyService.add(seller, num * PRICE);
        inventoryService.subtract(seller, num);

        moneyService.subtract(buyer, num * PRICE);
        inventoryService.add(buyer, num);
    }
}
